package nowcoder;

import java.util.Scanner;

/**
 * @author： hmm
 * @date： 2020/7/17 9:38
 * @description： 自守数
 * @modifiedBy：
 */
public class AutomorphicNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int count = 0;
        for (int j = 0; j<=i; j++) {
            String a = String.valueOf(j * j);
            String b = String.valueOf(j);
            if (a.charAt(a.length()-1) == b.charAt(b.length()-1)) {
                System.out.println(b);
                count ++;
            }
        }
        System.out.println(count);

    }
}
